Fix benchmark files: remove unused imports, fix Grievance seed data, move DB setup out of module scope#561
Merged
RohanExploit merged 2 commits intobolt-optimize-closure-count-queries-6106104410388610831from Mar 19, 2026
Conversation
…data, move DB setup out of module level Co-authored-by: RohanExploit <178623867+RohanExploit@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [6106104410388610831] Optimize closure status queries using GROUP BY
Fix benchmark files: remove unused imports, fix Grievance seed data, move DB setup out of module scope
Mar 19, 2026
RohanExploit
approved these changes
Mar 19, 2026
f7abfcc
into
bolt-optimize-closure-count-queries-6106104410388610831
Contributor
There was a problem hiding this comment.
Pull request overview
This PR cleans up and fixes the closure-status benchmark scripts introduced alongside the GROUP BY optimization work, ensuring benchmarks seed valid data and avoid unintended side effects during pytest collection.
Changes:
- Removes unused imports and unneeded path manipulation in the closure-status benchmark scripts.
- Fixes
seed_data()in the closure-status benchmark to satisfyGrievance/FK non-null constraints by creating aJurisdictionand setting required fields. - Moves in-memory SQLite setup in
test_closure_status_benchmark.pyintorun_benchmark()to prevent DB creation at import time.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| backend/tests/test_closure_status_benchmark.py | Moves SQLite engine/table setup into run_benchmark() and removes unused imports to avoid pytest collection side effects. |
| backend/tests/benchmark_closure_status.py | Updates benchmark seeding to create valid Jurisdiction/Grievance rows and removes unused imports/path hacks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+33
to
35
| assigned_authority="Municipal Corporation", | ||
| sla_deadline=datetime.utcnow() + timedelta(hours=72), | ||
| pincode="123456", |
Comment on lines
+2
to
6
| from datetime import datetime, timedelta | ||
|
|
||
| from sqlalchemy import create_engine | ||
| from sqlalchemy.orm import sessionmaker | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses four reviewer findings in the benchmark scripts added by the GROUP BY optimization PR.
Changes
backend/tests/benchmark_closure_status.pyget_db,ClosureService,patch,MagicMock,sys,ossys.path.insert(0, os.path.abspath('.'))— unnecessary when running viapython -mseed_data()to satisfy all non-null FK constraints: creates aJurisdictionrow first, then populatesGrievance.severity,current_jurisdiction_id,assigned_authority, andsla_deadlinebackend/tests/test_closure_status_benchmark.pysysandosimportscreate_engine,create_all, andsessionmakersetup insiderun_benchmark()— previously at module scope, causing DB creation as a side effect during pytest collectionType of Change
Related Issue
Closes #
Testing Done
Screenshots (if applicable)
Checklist
Co-Authors
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.
Summary by cubic
Optimize closure status queries by aggregating results with SQL GROUP BY. Speeds up closure count views and updates benchmarks to seed valid data and avoid module-level DB side effects.
Performance
Bug Fixes
Jurisdictionand requiredGrievancefields (severity,current_jurisdiction_id,assigned_authority,sla_deadline).run_benchmark()to prevent pytest collection side effects.Written for commit 62206ab. Summary will update on new commits.